﻿using System;
using fastCSharp;

namespace diantou.web.ajax
{
    /// <summary>
    /// 用户操作
    /// </summary>
    [fastCSharp.code.cSharp.ajax(IsPool = true)]
    class user : userHandle<user>
    {
        /// <summary>
        /// 修改用户姓名与描述
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void Rework(diantou.dataAccess.user value, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            value.Id = currentUser.Id;
            diantou.dataAccess.tcpCall.user.rework(value, onReturn);
        }
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="password"></param>
        /// <param name="newPassword"></param>
        /// <param name="verify"></param>
        /// <param name="onReturn"></param>
        public void ReworkPassword(string password, string newPassword, string verify
            , Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.reworkPassword(currentUser.Id, pub.GetPassword(password, verify), pub.GetPassword(newPassword, verify), onReturn);
        }
        /// <summary>
        /// 修改基本设置
        /// </summary>
        /// <param name="flags"></param>
        /// <param name="messageFlag"></param>
        /// <param name="onReturn"></param>
        public void ReworkMessageFlag(diantou.dataModel.user.flag flags, diantou.dataModel.user.messageFlag messageFlag
            , Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.reworkMessageFlag(currentUser.Id, flags, messageFlag, onReturn);
        }
        /// <summary>
        /// 修改通知设置
        /// </summary>
        /// <param name="noticeFlags"></param>
        /// <param name="onReturn"></param>
        public void ReworkNoticeFlag(diantou.dataModel.user.noticeFlag noticeFlags
            , Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.reworkNoticeFlag(currentUser.Id, noticeFlags, onReturn);
        }
        /// <summary>
        /// 访问动态
        /// </summary>
        /// <param name="logId"></param>
        /// <param name="onReturn"></param>
        public void VisitLog(int logId, Action<fastCSharp.net.returnValue> onReturn)
        {
            if (currentUser.IsChangeVisit)
            {
                diantou.dataAccess.tcpCall.user.visitFocus(currentUser.Id, logId, onReturn);
                return;
            }
            onReturn(new fastCSharp.net.returnValue { Type = fastCSharp.net.returnValue.type.Unknown });
        }
        /// <summary>
        /// 获取用户姓名
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        [fastCSharp.code.cSharp.ajax(IsOnlyPost = false)]
        public string GetName(int userId)
        {
            diantou.dataAccess.user user = diantou.dataAccess.clientCache.User[userId];
            return user != null ? user.Name : null;
        }
        /// <summary>
        /// 第三方登录电子邮件绑定
        /// </summary>
        /// <param name="email"></param>
        /// <param name="onReturn"></param>
        public void SetEmail(string email, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.setEmail(currentUser.Id, email, onReturn);
        }
        /// <summary>
        /// 获取教程第一个课程标识并支付点头盾
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void GetTutorial(int tutorialId, Action<fastCSharp.net.returnValue<int>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.getTutorial(currentUser.Id, tutorialId, onReturn);
        }
        /// <summary>
        /// 邮箱过期处理
        /// </summary>
        /// <param name="onReturn"></param>
        public void ExpiredEmail(Action<fastCSharp.net.returnValue<string>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.expiredEmail(currentUser.Id, onReturn);
        }
        /// <summary>
        /// 取消邮箱过期处理
        /// </summary>
        /// <param name="onReturn"></param>
        public void CancelExpiredEmail(Action<fastCSharp.net.returnValue<string>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.cancelExpiredEmail(currentUser.Id, onReturn);
        }
        /// <summary>
        /// 修改企业待审核信息
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void ReworkEnterpriseCheck(diantou.dataAccess.user value, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            value.Id = currentUser.Id;
            diantou.dataAccess.tcpCall.user.reworkEnterpriseCheck(value, onReturn);
        }
        /// <summary>
        /// 修改企业名称与简介
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void ReworkEnterprise(diantou.dataAccess.user value, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            value.Id = currentUser.Id;
            diantou.dataAccess.tcpCall.user.reworkEnterprise(value, onReturn);
        }
        /// <summary>
        /// 修改企业描述
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void ReworkEnterpriseDescription(string description, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.reworkEnterpriseDescription(currentUser.Id, description, onReturn);
        }
        /// <summary>
        /// 修改公司阶段
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void ReworkCompanyStage(diantou.dataModel.user.companyStage companyStage, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.rework(currentUser.Id, companyStage, onReturn);
        }
        /// <summary>
        /// 修改行业领域
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void ReworkIndustry(diantou.dataModel.user.industry industry, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.rework(currentUser.Id, industry, onReturn);
        }
        /// <summary>
        /// 修改企业规模
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void ReworkCompanySize(diantou.dataModel.user.companySize companySize, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.rework(currentUser.Id, companySize, onReturn);
        }
        /// <summary>
        /// 修改公司地址
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void ReworkCompanyAddress(diantou.dataModel.user.companyAddress companyAddress, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.rework(currentUser.Id, companyAddress, onReturn);
        }
        /// <summary>
        /// 修改企业福利
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void ReworkEnterpriseWelfare(string enterpriseWelfare, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.reworkEnterpriseWelfare(currentUser.Id, enterpriseWelfare, onReturn);
        }
        /// <summary>
        /// 购买服务有效期
        /// </summary>
        /// <param name="month"></param>
        /// <param name="onReturn"></param>
        public void BuyEnterpriseValidity(int month, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            diantou.examDataAccess.tcpCall.enterprise.buyEnterpriseValidity(currentUser.Id, month, onReturn);
        }
        /// <summary>
        /// 购买独占题库服务有效期
        /// </summary>
        /// <param name="month"></param>
        /// <param name="onReturn"></param>
        public void BuyEnterprisePrivateValidity(int month, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            diantou.examDataAccess.tcpCall.enterprise.buyEnterprisePrivateValidity(currentUser.Id, month, onReturn);
        }
        /// <summary>
        /// 获取手机验证码
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="onReturn"></param>
        public void GetMobileCode(long mobile, Action<fastCSharp.net.returnValue<int>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.getMobileCode(currentUser.Id, mobile, onReturn);
        }
        /// <summary>
        /// 手机验证
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="mobileCode"></param>
        /// <param name="onReturn"></param>
        public void MobileVerify(long mobile, string mobileCode, Action<fastCSharp.net.returnValue<int>> onReturn)
        {
            diantou.dataAccess.tcpCall.user.mobileVerify(currentUser.Id, mobile, mobileCode, onReturn);
        }
        /// <summary>
        /// 修改个人信息
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void ReworkRemittance(diantou.dataAccess.user value, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            value.Id = currentUser.Id;
            diantou.dataAccess.tcpCall.user.reworkRemittance(value, onReturn);
        }
    }
}
